home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / XPDeque.hP < prev    next >
Text File  |  1992-04-14  |  3KB  |  134 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.     based on code by Marc Shapiro (shapiro@sor.inria.fr)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20.  
  21. #ifndef _<T>XPDeque_h
  22. #ifdef __GNUG__
  23. #pragma interface
  24. #endif
  25. #define _<T>XPDeque_h
  26.  
  27. #include "<T>.XPlex.h"
  28. #include "<T>.Deque.h"
  29.  
  30. class <T>XPDeque : public <T>Deque
  31. {
  32.   <T>XPlex     p;
  33.  
  34. public:
  35.                <T>XPDeque(int chunksize = DEFAULT_INITIAL_CAPACITY);
  36.                <T>XPDeque(const <T>XPDeque& d);
  37.                ~<T>XPDeque();
  38.  
  39.   void          operator = (const <T>XPDeque&);
  40.  
  41.   void          push(<T&> item); // insert at front
  42.   void          enq(<T&> item);  // insert at rear
  43.  
  44.   <T>&          front();
  45.   <T>&          rear();
  46.  
  47.   <T>           deq();
  48.   void          del_front();
  49.   void          del_rear();               
  50.  
  51.   void          clear();
  52.   int           empty();
  53.   int           full();
  54.   int           length();
  55.                
  56.   int           OK();
  57. };
  58.  
  59. inline <T>XPDeque::<T>XPDeque(int chunksize) 
  60.      : p(chunksize) {}
  61. inline <T>XPDeque::<T>XPDeque(const <T>XPDeque& d) : p(d.p) {}
  62.  
  63. inline <T>XPDeque::~<T>XPDeque() {}
  64.  
  65. inline void <T>XPDeque::push(<T&>item)
  66. {
  67.   p.add_low(item);
  68. }
  69.  
  70. inline void <T>XPDeque::enq(<T&>item)
  71. {
  72.   p.add_high(item);
  73. }
  74.  
  75. inline <T> <T>XPDeque::deq()
  76. {
  77.   <T> res = p.low_element();
  78.   p.del_low();
  79.   return res;
  80. }
  81.  
  82. inline <T>& <T>XPDeque::front()
  83. {
  84.   return p.low_element();
  85. }
  86.  
  87. inline <T>& <T>XPDeque::rear()
  88. {
  89.   return p.high_element();
  90. }
  91.  
  92. inline void <T>XPDeque::del_front()
  93. {
  94.   p.del_low();
  95. }
  96.  
  97. inline void <T>XPDeque::del_rear()
  98. {
  99.   p.del_high();
  100. }
  101.  
  102. inline void <T>XPDeque::operator =(const <T>XPDeque& s)
  103. {
  104.   p.operator = (s.p);
  105. }
  106.  
  107.  
  108. inline int <T>XPDeque::empty()
  109. {
  110.   return p.empty();
  111. }
  112.  
  113. inline int <T>XPDeque::full()
  114. {
  115.   return p.full();
  116. }
  117.  
  118. inline int <T>XPDeque::length()
  119. {
  120.   return p.length();
  121. }
  122.  
  123. inline int <T>XPDeque::OK()
  124. {
  125.   return p.OK();
  126. }
  127.  
  128. inline void <T>XPDeque::clear()
  129. {
  130.   p.clear();
  131. }
  132.  
  133. #endif
  134.